<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:72:"D:\phpStudy\WWW\oa\public/../application/index\view\stafflist\index.html";i:1519966729;}*/ ?>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title>网站信息</title>
    <link rel="stylesheet" href="__CSS__/pintuer.css">
    <link rel="stylesheet" href="__CSS__/admin.css">
    <link rel="stylesheet" href="__STATIC__/css/layui.css">
    <script src="__STATIC__/layui.js"></script>
    <script src="__JS__/jquery.js"></script>
    <script src="__JS__/pintuer.js"></script>
</head>
<body>
<div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> 员工列表</strong>&emsp;<a
            style="color: #3a4bfb;font-weight: bold " href="javascript:history.go(-1)">返回上一步</a></div>
    <form class="layui-form" action="<?php echo url('Stafflist/index'); ?>" method="post">
        <div style="margin-top: 1%;margin-left: 1%" class="layui-form-item">
            <div class="layui-inline">
                <label style="float: left;margin-top: 10px" class="layui-form-lable">主体：</label>
                <div class="layui-input-inline">
                    <select name="region_id" id="region_id" lay-filter="region_id" lay-search="">
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label style="float: left;margin-top: 10px" class="layui-form-lable">部门：</label>
                <div class="layui-input-inline">
                    <select name="branch_id" id="branch_id" lay-filter="branch_id" lay-search="">
                    </select>
                </div>
            </div>
        </div>
        <div style="margin-left: 1%" class="layui-form-item">
            <div class="layui-inline">
                <label style="float: left;margin-top: 10px" class="layui-form-lable">姓名：</label>
                <div class="layui-input-inline">
                    <input  placeholder="请输入你要搜索的员工姓名" type="text" name="ch_name" id="ch_name" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label style="float: left;margin-top: 10px" class="layui-form-lable">职位：</label>
                <div class="layui-input-inline">
                    <input  placeholder="请输入你要搜索的员工职位" type="text" name="position" id="position" class="layui-input">
                </div>
            </div>
            <div style="float: right;margin-right: 35%;" class="layui-input-block">
                <button name="submit" class="layui-btn" lay-submit="" lay-filter="demo">立即搜索</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
        <div class="layui-form-item">

        </div>
    </form>
    <!--<a class="button border-yellow" href=""><span class="icon-plus-square-o"></span> 添加内容</a>-->
</div>
<div id="div">
    <table id="demo" lay-filter="demo">
        <thead>
        <tr>
            <th lay-data="{field:'id',sort:'true', align:'center'}">ID</th>
            <th lay-data="{field:'ch_name',sort: true, align:'center'}">姓名</th>
            <th lay-data="{field:'region',sort: true, align:'center'}">主体</th>
            <th lay-data="{field:'branch',sort: true, align:'center'}">部门</th>
            <th lay-data="{field:'position',sort: true, align:'center'}">职位</th>
            <th lay-data="{fixed: 'right', align:'center', toolbar: '#barDemo'}">操作</th>
        </tr>
        </thead>
        <tbody>
        <?php if(is_array($list) || $list instanceof \think\Collection || $list instanceof \think\Paginator): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
        <tr>
            <td><?php if($vo['id'] == null): ?>无<?php else: ?><?php echo $vo['id']; endif; ?></td>
            <td><?php if($vo['ch_name'] == null): ?>无<?php else: ?><?php echo $vo['ch_name']; endif; ?></td>
            <td><?php if($vo['region'] == null): ?>无<?php else: ?><?php echo $vo['region']; endif; ?></td>
            <td><?php if($vo['branch'] == null): ?>无<?php else: ?><?php echo $vo['branch']; endif; ?></td>
            <td><?php if($vo['position'] == null): ?>无<?php else: ?><?php echo $vo['position']; endif; ?></td>
            <?php if($vo['id'] == null): ?><td></td><?php else: ?>
            <td lay-data="{fixed: 'right', width:178, align:'center', toolbar: '#barDemo'}">
                <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
                <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a></td>
            <?php endif; ?>
        </tr>
        <?php endforeach; endif; else: echo "" ;endif; ?>
        </tbody>
    </table>
</div>

</div>
<div>
</div>
</body>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
    <a class="layui-btn layui-btn-xs" lay-event="edit">修改</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script>
    layui.use(['table', 'layer','form'], function () {
        var table = layui.table
            ,laypage = layui.laypage
            , form =layui.form
            , layer = layui.layer;
        var num=0;
        $.getJSON("<?php echo url('Base/liandong_c'); ?>",function (data_a) {
            $.each(data_a.datalist,function (i,item) {
                if (i==0){
                    num=item.id
                }
                $('#region_id').append("<option value="+item.id+">"+item.region+"</option>");
            });
            $.getJSON("<?php echo url('Base/liandong_d'); ?>?region_id="+num,function (data_b) {
                $.each(data_b.datalist,function (j,res) {
                    $('#branch_id').append("<option value="+res.id+">"+res.branch+"</option>")
                });
                form.render('select');
            })
        });
        form.on('select(region_id)',function (data_aa) {
            var region_ids=data_aa.value;
            $('#branch_id').html('');
            $.getJSON("<?php echo url('Base/liandong_d'); ?>?region_id="+region_ids,function (data_bb) {
                $.each(data_bb.datalist, function (i, item) {
                    $('#branch_id').append('<option  value=' + item.id + '>' + item.branch + "</option>");
                });
                form.render('select');
            })
        });
        $('.demoTable .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        //监听工具条(修改删除查看)
        table.on('tool(demo)', function (obj) {
            var data = obj.data;
            if (obj.event === 'detail') {
                layer.msg('姓名：' + data.ch_name);
            } else if (obj.event === 'del') {
                dels(data.id);
                //layer.close(admin);
            } else if (obj.event === 'edit') {
                window.location.href = "<?php echo url('Staffsaves/index'); ?>" + "?id=" + data.id;
                //window.location.href="login.jsp?backurl="+window.location.href;
            }
        });
        table.init('demo', {
            //设置高度
            height: 350
            /*,first: false
            ,last: false*/
            //注意：请务必确保 limit 参数（默认：10）是与你服务端限定的数据条数一致
//支持所有基础参数
            , page: {
                layout: ['count','prev', 'page', 'next', 'skip', 'limit']
                ,curr: 1
               /* ,groups:3*/
            }
        });
    })
</script>
<script>
    function dels(id) {
        //插件表格删除
        layui.use(['layer'], function () {
            var layer = layui.layer;
            layer.confirm('你确定要删除吗', {icon: 7, title: '提示'}, function (index) {
                var submit = "submit";
                $.ajax({
                    type: "post",
                    url: "<?php echo url('Stafflist/staffdel'); ?>",
                    data: {"id": id, 'submit': submit},
                    dataType: "json",
                    success: function (a) {
                        //alert(10);
                        if (a) {
                            layer.msg('删除成功', {icon: 1});
                            layer.close(index);
                        } else {
                            layer.msg('删除失败', {icon: 2});
                            layer.close(index);
                        }
                        setTimeout(function () {
                            //使用  setTimeout（）方法设定定时2000<a href="https://www.baidu.com/s?wd=%E6%AF%AB%E7%A7%92&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWuHn4n1DkmynYmhu9uhcd0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHf4PWmsrHRdnWckPWnkrHmkrf" target="_blank" class="baidu-highlight">毫秒</a>
                            window.location.reload();//页面刷新
                        }, 2000);
                    }

                })
            })

        });
        //表格删除
        /*if (confirm("您确定要删除吗?")) {
         $.ajax({
         type: "post",
         url: "<?php echo url('Stafflist/staffdel'); ?>",
         data: {"id": id},
         dataType: "json",
         success: function (a) {
         if (a) {
         alert("删除成功");
         window.location.replace("<?php echo url('Stafflist/admin'); ?>")
         } else {
         alert("删除失败")
         }
         }
         })
         }*/
    }
</script>

</html>